package cn.tedu.lucky.draw.user.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.CoreSubscriber;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.Arrays;
import java.util.List;

@RestController
public class TestController {

    @GetMapping("/test")
    public Mono<String> test() {
        String message = "Hello, WebFlux!";
        return Mono.just(null);
    }

    @GetMapping("/test-justOrEmpty")
    public Mono<String> justOrEmpty() {
        return Mono.justOrEmpty(null);
    }

    @GetMapping("/test-fluxJust")
    public Flux<String> fluxJust() {
        return Flux.just("卫老师摧毁停车场", "鹏宇老师坐飞机", "常老师练散打");
    }

    @GetMapping("/test-fluxFromIterable")
    public Flux<String> fluxFromIterable() {
        List<String> stringList = Arrays.asList("卫老师摧毁停车场", "鹏宇老师坐飞机", "常老师练散打");
        return Flux.fromIterable(stringList);
    }

    @GetMapping("/test-empty")
    public Flux<String> empty() {
        return Flux.empty();
    }

}
